#ifndef CORE_DATA_UNIT_CLASS
#define CORE_DATA_UNIT_CLASS

#include <string>
#include <iostream>
#include <stdlib.h>

namespace pland
{

/*! Routing header for Data. */
typedef struct Data_Header_Struct
{
    /*! Global creation timestamp used for tracking latency */
    unsigned int secGlobal;
    unsigned int usecGlobal;

    /*! Local creation timestamp used for tracking latency */
    unsigned int secLocal;
    unsigned int usecLocal;
    /*! Used for reasembling the stream if required */
    uint sequenceNumber;
    /*! Tag assosiated with the data */
    int tag;
    /*! Data size. */
    int size;
} Data_Header;


/*!
 * \brief A core Data Unit. This class is used to pass data throughout the program.
 */

class Data
{
public:

    /*! Default Constructor, creates uninitialized data unit. */
    Data();

    /*! Copy Constructor, for deep copy.
         * \param o data unit to be copied.*/
    Data(const Data& o);

    /*! Create and initialize the data unit.
         * \param data pointer to the event data.
         * \param Header routing header.
         */
    Data(void*, Data_Header* header);

    /*! Default Destructor */
    ~Data();

    /*! Initialize data unit.
         * \param data pointer to the event data.
         * \param header header associated event.
         */
    void load_data(void* data, Data_Header* header);

    /*! Uninitialize the data storage. */
    void clear();

    /*!
         * Get the routing header.
         * \return routing header.
         */
    Data_Header* get_header();

    /*! Check if the structure is initialized.
         *  \return true if the structure is initialized, false otherwise.
         */
    bool is_inited();

    /*! Get the event attached to the class.
         * \return attached data, NUll if structure is uninitialized.
         */
    void* get_data();
private:
    /*! Pointer to event data.*/
	void* data_;
    /*! Routing header */
	Data_Header * header_;
    /*! Initialized flag*/
	bool filled_;
};
}
#endif /*coredataunit.hpp*/
